//
//  JsVolumnManager.m
//  MixedPlayerSdk
//
//  Created by Gikki Ares on 2021/11/22.
//

#import "JsVolumnManager.h"
#import <MediaPlayer/MediaPlayer.h>
#import <AVFoundation/AVFoundation.h>

@interface JsVolumnManager()

@end

@implementation JsVolumnManager
static MPVolumeView * volumeView;
static UISlider * volumeSlider;
//在app刚刚初始化的时候使用MPVolumeView获取音量大小可能为0
+ (float) getCurrentVolumn2 {
	if(!volumeView) {
		volumeView = [[MPVolumeView alloc]initWithFrame:CGRectMake(-100, -100, 40, 40)];
		for(UIView*view in[volumeView subviews]) {
			if([[[view class] description] isEqualToString:@"MPVolumeSlider"]) {
				volumeSlider = (UISlider*) view;
			}
		}
	}
	[[UIApplication sharedApplication].keyWindow addSubview:volumeView];
	float value = volumeSlider.value;
	return value;
}

+ (float) getCurrentVolumn {
	float value = [[AVAudioSession sharedInstance] outputVolume];
	return value;
}

+ (void) setVolumn:(float)volumn {
	
}

@end
